﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ModularFixture.CUiMFSetFixtureBasePlacementPointsDlg
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using C1.Win.C1FlexGrid;
using C1.Win.C1FlexGrid.Util.BaseControls;
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Resources;
using System.Windows.Forms;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.Ui;
using Tecnomatix.Engineering.Ui48;
using Tecnomatix.Planning;


namespace DnProcessSimulateCommands.ModularFixture;

public class CUiMFSetFixtureBasePlacementPointsDlg : TxForm
{
  private ArrayList m_pointsList;
  private bool isNewPointCreated;
  private ResourceManager m_resourceManager;
  private CApMFFixtureBaseTypeData m_fixtureBaseData;
  private IContainer components;
  private double m_value;
  private Button m_okButton;
  private Button m_newButton;
  private Button m_deleteButton;
  private CheckBox m_intermediateCheckBox;
  private TxFlexGrid m_flexGrid;
  private ListView m_pointsListView;
  private ColumnHeader m_columnHeader;
  private TxObjEditBoxCtrl m_intermediateUnitText;
  private Button m_cancelButton;

  internal CUiMFSetFixtureBasePlacementPointsDlg(CApMFFixtureBaseTypeData fixtureBaseData)
  {
    this.InitializeComponent();
    this.m_resourceManager = CApMFAdminUtils.m_resourceManager;
    this.InitIntermediateNameField();
    this.disableAllCells();
    ((C1FlexGridBase) this.m_flexGrid)[1, 0] = (object) "X:";
    ((C1FlexGridBase) this.m_flexGrid)[2, 0] = (object) "Y:";
    ((C1FlexGridBase) this.m_flexGrid)[3, 0] = (object) "Z:";
    ((C1FlexGridBase) this.m_flexGrid)[4, 0] = (object) "RX:";
    ((C1FlexGridBase) this.m_flexGrid)[5, 0] = (object) "RY:";
    ((C1FlexGridBase) this.m_flexGrid)[6, 0] = (object) "RZ:";
    this.m_fixtureBaseData = fixtureBaseData;
    this.m_pointsList = this.m_fixtureBaseData.PlacementPoints;
    for (int index = 0; index < this.m_pointsList.Count; ++index)
    {
      CApMFPlacementPoint points = (CApMFPlacementPoint) this.m_pointsList[index];
      ListViewItem listViewItem = new ListViewItem(points.Name);
      listViewItem.Tag = (object) points;
      this.m_pointsListView.Items.Add(listViewItem);
      this.isNewPointCreated = true;
      this.m_pointsListView.Select();
      listViewItem.Selected = true;
      ((Control) this.m_flexGrid).Enabled = true;
      this.m_deleteButton.Enabled = true;
      if (this.m_pointsListView.Items.Count > 5)
        this.m_columnHeader.Width = 135;
    }
  }

  private void InitIntermediateNameField()
  {
    this.m_intermediateUnitText.SetValidator((ITxValidator) new CApMFUnitValidator());
    this.m_intermediateUnitText.SetPickProviders(new TxPickProvider[2]
    {
      (TxPickProvider) 4,
      (TxPickProvider) 6
    });
    this.m_intermediateUnitText.ListenToPick = true;
    this.m_intermediateUnitText.ReadOnly = true;
  }

  private void m_okButton_Click(object sender, EventArgs e)
  {
    ListView.SelectedListViewItemCollection selectedItems = this.m_pointsListView.SelectedItems;
    if (selectedItems.Count > 0 && selectedItems[0] != null)
      this.SaveChangedPoint((CApMFPlacementPoint) selectedItems[0].Tag);
    this.m_fixtureBaseData.PlacementPoints = this.m_pointsList;
    ((Form) this).Close();
  }

  private void m_cancelButton_Click(object sender, EventArgs e) => ((Form) this).Close();

  private void m_newButton_Click(object sender, EventArgs e)
  {
    int num = 1;
    string str;
    while (true)
    {
      str = "Point" + num.ToString();
      if (this.isPointExist(str))
        ++num;
      else
        break;
    }
    ListView.SelectedListViewItemCollection selectedItems = this.m_pointsListView.SelectedItems;
    if (selectedItems.Count == 1)
    {
      CApMFPlacementPoint tag = (CApMFPlacementPoint) selectedItems[0].Tag;
      for (int index = 0; index < this.m_pointsList.Count; ++index)
      {
        if (tag.Name == ((CApMFPlacementPoint) this.m_pointsList[index]).Name)
        {
          this.setPointValues((CApMFPlacementPoint) this.m_pointsList[index]);
          break;
        }
      }
    }
    CApMFPlacementPointGridRow x = new CApMFPlacementPointGridRow();
    CApMFPlacementPointGridRow y = new CApMFPlacementPointGridRow();
    CApMFPlacementPointGridRow z = new CApMFPlacementPointGridRow();
    CApMFPlacementPointGridRow rx = new CApMFPlacementPointGridRow();
    CApMFPlacementPointGridRow ry = new CApMFPlacementPointGridRow();
    CApMFPlacementPointGridRow rz = new CApMFPlacementPointGridRow();
    CApMFPlacementPoint point = new CApMFPlacementPoint(str, x, y, z, rx, ry, rz);
    this.m_pointsList.Add((object) point);
    this.setGridValues(point);
    for (int row = 1; row < 7; ++row)
      this.setCellsStyle("Exact", row);
    ListViewItem listViewItem = new ListViewItem(str);
    listViewItem.Tag = (object) point;
    this.m_pointsListView.Items.Add(listViewItem);
    this.isNewPointCreated = true;
    this.m_pointsListView.Select();
    listViewItem.Selected = true;
    ((Control) this.m_flexGrid).Enabled = true;
    this.m_deleteButton.Enabled = true;
    if (this.m_pointsListView.Items.Count > 5)
      this.m_columnHeader.Width = 135;
    this.m_intermediateCheckBox.Checked = false;
    this.m_intermediateUnitText.ReadOnly = true;
  }

  private void m_flexGrid_AfterEdit(object sender, RowColEventArgs e)
  {
    if (e.Col != 1)
      return;
    this.setCellsStyle((string) ((C1FlexGridBase) this.m_flexGrid)[e.Row, 1], e.Row);
  }

  private void m_flexGrid_BeforeEdit(object sender, RowColEventArgs e)
  {
    if (e.Row <= 0 || e.Col <= 1)
      return;
    CellStyle cellStyle = ((C1FlexGridBase) this.m_flexGrid).GetCellStyle(e.Row, e.Col);
    if (cellStyle == null || !(cellStyle.Name == "Fixed"))
      return;
    e.Cancel = true;
  }

  private void m_flexGrid_BeforeSelChange(object sender, RangeEventArgs e)
  {
    TxFlexGrid flexGrid1 = this.m_flexGrid;
    CellRange oldRange1 = e.OldRange;
    int topRow1 = ((CellRange) ref oldRange1).TopRow;
    CellRange cellRange;
    if (((C1FlexGridBase) flexGrid1)[topRow1, 3] != null)
    {
      TxFlexGrid flexGrid2 = this.m_flexGrid;
      CellRange oldRange2 = e.OldRange;
      int topRow2 = ((CellRange) ref oldRange2).TopRow;
      if (((C1FlexGridBase) flexGrid2)[topRow2, 4] != null)
      {
        CellRange oldRange3 = e.OldRange;
        if (((CellRange) ref oldRange3).LeftCol != 3)
        {
          CellRange oldRange4 = e.OldRange;
          if (((CellRange) ref oldRange4).LeftCol != 4)
            goto label_6;
        }
        TxFlexGrid flexGrid3 = this.m_flexGrid;
        CellRange oldRange5 = e.OldRange;
        int topRow3 = ((CellRange) ref oldRange5).TopRow;
        double num1 = (double) ((C1FlexGridBase) flexGrid3)[topRow3, 3];
        TxFlexGrid flexGrid4 = this.m_flexGrid;
        CellRange oldRange6 = e.OldRange;
        int topRow4 = ((CellRange) ref oldRange6).TopRow;
        double num2 = (double) ((C1FlexGridBase) flexGrid4)[topRow4, 4];
        if (num1 >= num2)
        {
          int num3 = (int) TxMessageBox.Show(this.m_resourceManager.GetString("MIN_MAX_ERROR_MESSAGE"), this.m_resourceManager.GetString("CMD_CONFIGURATION_ADMINISTRATOR_NAME"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
          TxFlexGrid flexGrid5 = this.m_flexGrid;
          CellRange oldRange7 = e.OldRange;
          int topRow5 = ((CellRange) ref oldRange7).TopRow;
          cellRange = e.OldRange;
          int leftCol = ((CellRange) ref cellRange).LeftCol;
          // ISSUE: variable of a boxed type
          __Boxed<double> local = (ValueType) this.m_value;
          ((C1FlexGridBase) flexGrid5)[topRow5, leftCol] = (object) local;
        }
      }
    }
label_6:
    cellRange = e.NewRange;
    if (((CellRange) ref cellRange).LeftCol != 3)
    {
      cellRange = e.NewRange;
      if (((CellRange) ref cellRange).LeftCol != 4)
        return;
    }
    TxFlexGrid flexGrid6 = this.m_flexGrid;
    cellRange = e.NewRange;
    int topRow6 = ((CellRange) ref cellRange).TopRow;
    cellRange = e.NewRange;
    int leftCol1 = ((CellRange) ref cellRange).LeftCol;
    if (((C1FlexGridBase) flexGrid6)[topRow6, leftCol1] == null)
      return;
    TxFlexGrid flexGrid7 = this.m_flexGrid;
    cellRange = e.NewRange;
    int topRow7 = ((CellRange) ref cellRange).TopRow;
    cellRange = e.NewRange;
    int leftCol2 = ((CellRange) ref cellRange).LeftCol;
    this.m_value = (double) ((C1FlexGridBase) flexGrid7)[topRow7, leftCol2];
  }

  private void m_deleteButton_Click(object sender, EventArgs e)
  {
    ListView.SelectedListViewItemCollection selectedItems = this.m_pointsListView.SelectedItems;
    if (selectedItems.Count == 1)
    {
      ListViewItem listViewItem = selectedItems[0];
      this.m_pointsListView.Items.Remove(listViewItem);
      this.m_pointsList.Remove(listViewItem.Tag);
      if (this.m_pointsList.Count == 0)
      {
        ((Control) this.m_flexGrid).Enabled = false;
        this.m_deleteButton.Enabled = false;
        this.disableAllCells();
      }
      else
      {
        this.m_pointsListView.Select();
        this.m_pointsListView.Items[0].Selected = true;
        this.m_pointsListView.Items[0].EnsureVisible();
      }
    }
    if (this.m_pointsListView.Items.Count >= 6)
      return;
    this.m_columnHeader.Width = 151;
  }

  private void m_pointsListView_AfterLabelEdit(object sender, LabelEditEventArgs e)
  {
    if (!this.isPointExist(e.Label))
      return;
    int num = (int) TxMessageBox.Show(this.m_resourceManager.GetString("PLACEMENT_POINTS_POINT_EXIST"), this.m_resourceManager.GetString("PLACEMENT_POINTS_CAPTION"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
    e.CancelEdit = true;
  }

  private void m_pointsListView_ItemSelectionChanged(
    object sender,
    ListViewItemSelectionChangedEventArgs e)
  {
    CApMFPlacementPoint tag = (CApMFPlacementPoint) e.Item.Tag;
    if (!e.IsSelected)
    {
      this.SaveChangedPoint(tag);
    }
    else
    {
      this.setGridValues(tag);
      this.setCellsStyle(this.TypeToString(tag.X.Type), 1);
      this.setCellsStyle(this.TypeToString(tag.Y.Type), 2);
      this.setCellsStyle(this.TypeToString(tag.Z.Type), 3);
      this.setCellsStyle(this.TypeToString(tag.RX.Type), 4);
      this.setCellsStyle(this.TypeToString(tag.RY.Type), 5);
      this.setCellsStyle(this.TypeToString(tag.RZ.Type), 6);
      if (tag.IntermediateUnitId > 0)
      {
        ITxPlanningObject objectByInternalId = (TxApplication.ActiveDocument.PlatformGlobalServicesProvider as TxEmsGlobalServicesProvider).GetObjectByInternalId(tag.IntermediateUnitId);
        this.m_intermediateCheckBox.Checked = true;
        this.m_intermediateUnitText.ReadOnly = false;
        this.m_intermediateUnitText.Object = (ITxObject) objectByInternalId;
      }
      else
      {
        this.m_intermediateCheckBox.Checked = false;
        this.m_intermediateUnitText.Object = (ITxObject) null;
        ((Control) this.m_intermediateUnitText).Text = "";
        this.m_intermediateUnitText.ReadOnly = true;
      }
    }
  }

  private bool isPointExist(string strPoint)
  {
    foreach (ListViewItem listViewItem in this.m_pointsListView.Items)
    {
      if (strPoint == listViewItem.Text)
        return true;
    }
    return false;
  }

  private void setCellsStyle(string newType, int row)
  {
    ((C1FlexGridBase) this.m_flexGrid).SetCellStyle(row, 1, "");
    CellStyle style = ((C1FlexGridBase) this.m_flexGrid).Styles["Fixed"];
    switch (newType)
    {
      case "Step":
      case "Free":
        ((C1FlexGridBase) this.m_flexGrid)[row, 2] = (object) null;
        ((C1FlexGridBase) this.m_flexGrid).SetCellStyle(row, 2, style);
        if (((C1FlexGridBase) this.m_flexGrid)[row, 3] == null)
          ((C1FlexGridBase) this.m_flexGrid)[row, 3] = (object) -100;
        ((C1FlexGridBase) this.m_flexGrid).SetCellStyle(row, 3, "");
        if (((C1FlexGridBase) this.m_flexGrid)[row, 4] == null)
          ((C1FlexGridBase) this.m_flexGrid)[row, 4] = (object) 100;
        ((C1FlexGridBase) this.m_flexGrid).SetCellStyle(row, 4, "");
        if (newType == "Step")
        {
          if (((C1FlexGridBase) this.m_flexGrid)[row, 5] == null)
            ((C1FlexGridBase) this.m_flexGrid)[row, 5] = (object) 10;
          ((C1FlexGridBase) this.m_flexGrid).SetCellStyle(row, 5, "");
          break;
        }
        ((C1FlexGridBase) this.m_flexGrid)[row, 5] = (object) null;
        ((C1FlexGridBase) this.m_flexGrid).SetCellStyle(row, 5, style);
        break;
      case "Exact":
        if (((C1FlexGridBase) this.m_flexGrid)[row, 2] == null)
          ((C1FlexGridBase) this.m_flexGrid)[row, 2] = (object) 0;
        ((C1FlexGridBase) this.m_flexGrid).SetCellStyle(row, 2, "");
        ((C1FlexGridBase) this.m_flexGrid)[row, 3] = (object) null;
        ((C1FlexGridBase) this.m_flexGrid).SetCellStyle(row, 3, style);
        ((C1FlexGridBase) this.m_flexGrid)[row, 4] = (object) null;
        ((C1FlexGridBase) this.m_flexGrid).SetCellStyle(row, 4, style);
        ((C1FlexGridBase) this.m_flexGrid)[row, 5] = (object) null;
        ((C1FlexGridBase) this.m_flexGrid).SetCellStyle(row, 5, style);
        break;
    }
  }

  private void setGridValues(CApMFPlacementPoint point)
  {
    ((C1FlexGridBase) this.m_flexGrid)[1, 1] = (object) point.X.Type;
    ((C1FlexGridBase) this.m_flexGrid)[1, 2] = (object) point.X.Value;
    ((C1FlexGridBase) this.m_flexGrid)[1, 3] = (object) point.X.Min;
    ((C1FlexGridBase) this.m_flexGrid)[1, 4] = (object) point.X.Max;
    ((C1FlexGridBase) this.m_flexGrid)[1, 5] = (object) point.X.Step;
    ((C1FlexGridBase) this.m_flexGrid)[2, 1] = (object) point.Y.Type;
    ((C1FlexGridBase) this.m_flexGrid)[2, 2] = (object) point.Y.Value;
    ((C1FlexGridBase) this.m_flexGrid)[2, 3] = (object) point.Y.Min;
    ((C1FlexGridBase) this.m_flexGrid)[2, 4] = (object) point.Y.Max;
    ((C1FlexGridBase) this.m_flexGrid)[2, 5] = (object) point.Y.Step;
    ((C1FlexGridBase) this.m_flexGrid)[3, 1] = (object) point.Z.Type;
    ((C1FlexGridBase) this.m_flexGrid)[3, 2] = (object) point.Z.Value;
    ((C1FlexGridBase) this.m_flexGrid)[3, 3] = (object) point.Z.Min;
    ((C1FlexGridBase) this.m_flexGrid)[3, 4] = (object) point.Z.Max;
    ((C1FlexGridBase) this.m_flexGrid)[3, 5] = (object) point.Z.Step;
    ((C1FlexGridBase) this.m_flexGrid)[4, 1] = (object) point.RX.Type;
    ((C1FlexGridBase) this.m_flexGrid)[4, 2] = (object) point.RX.Value;
    ((C1FlexGridBase) this.m_flexGrid)[4, 3] = (object) point.RX.Min;
    ((C1FlexGridBase) this.m_flexGrid)[4, 4] = (object) point.RX.Max;
    ((C1FlexGridBase) this.m_flexGrid)[4, 5] = (object) point.RX.Step;
    ((C1FlexGridBase) this.m_flexGrid)[5, 1] = (object) point.RY.Type;
    ((C1FlexGridBase) this.m_flexGrid)[5, 2] = (object) point.RY.Value;
    ((C1FlexGridBase) this.m_flexGrid)[5, 3] = (object) point.RY.Min;
    ((C1FlexGridBase) this.m_flexGrid)[5, 4] = (object) point.RY.Max;
    ((C1FlexGridBase) this.m_flexGrid)[5, 5] = (object) point.RY.Step;
    ((C1FlexGridBase) this.m_flexGrid)[6, 1] = (object) point.RZ.Type;
    ((C1FlexGridBase) this.m_flexGrid)[6, 2] = (object) point.RZ.Value;
    ((C1FlexGridBase) this.m_flexGrid)[6, 3] = (object) point.RZ.Min;
    ((C1FlexGridBase) this.m_flexGrid)[6, 4] = (object) point.RZ.Max;
    ((C1FlexGridBase) this.m_flexGrid)[6, 5] = (object) point.RZ.Step;
  }

  private void setPointValues(CApMFPlacementPoint point)
  {
    point.X.Type = this.StringToType((string) ((C1FlexGridBase) this.m_flexGrid)[1, 1]);
    this.fillXData(point);
    point.Y.Type = this.StringToType((string) ((C1FlexGridBase) this.m_flexGrid)[2, 1]);
    this.fillYData(point);
    point.Z.Type = this.StringToType((string) ((C1FlexGridBase) this.m_flexGrid)[3, 1]);
    this.fillZData(point);
    point.RX.Type = this.StringToType((string) ((C1FlexGridBase) this.m_flexGrid)[4, 1]);
    this.fillRXData(point);
    point.RY.Type = this.StringToType((string) ((C1FlexGridBase) this.m_flexGrid)[5, 1]);
    this.fillRYData(point);
    point.RZ.Type = this.StringToType((string) ((C1FlexGridBase) this.m_flexGrid)[6, 1]);
    this.fillRZData(point);
    if (this.m_intermediateCheckBox.Checked)
    {
      if (this.m_intermediateUnitText.Object != null)
      {
        TxEmsServicesProvider servicesProvider = (this.m_intermediateUnitText.Object as ITxPlanningObject).PlatformServicesProvider as TxEmsServicesProvider;
        point.IntermediateUnitId = servicesProvider.InternalId;
      }
      else
      {
        int num = (int) TxMessageBox.Show(this.m_resourceManager.GetString("INTERMEDIATE_NOT_CHOSEN_ERROR_MESSAGE"), this.m_resourceManager.GetString("CMD_CONFIGURATION_ADMINISTRATOR_NAME"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
      }
    }
    else
      point.IntermediateUnitId = 0;
  }

  private void fillXData(CApMFPlacementPoint point)
  {
    if (point.X.Type == PointType.Step || point.X.Type == PointType.Free)
    {
      point.X.Min = (double) ((C1FlexGridBase) this.m_flexGrid)[1, 3];
      point.X.Max = (double) ((C1FlexGridBase) this.m_flexGrid)[1, 4];
      if (point.X.Type != PointType.Step)
        return;
      point.X.Step = (double) ((C1FlexGridBase) this.m_flexGrid)[1, 5];
    }
    else
    {
      if (point.X.Type != PointType.Exact)
        return;
      point.X.Value = (double) ((C1FlexGridBase) this.m_flexGrid)[1, 2];
    }
  }

  private void fillYData(CApMFPlacementPoint point)
  {
    if (point.Y.Type == PointType.Step || point.Y.Type == PointType.Free)
    {
      point.Y.Min = (double) ((C1FlexGridBase) this.m_flexGrid)[2, 3];
      point.Y.Max = (double) ((C1FlexGridBase) this.m_flexGrid)[2, 4];
      if (point.Y.Type != PointType.Step)
        return;
      point.Y.Step = (double) ((C1FlexGridBase) this.m_flexGrid)[2, 5];
    }
    else
    {
      if (point.Y.Type != PointType.Exact)
        return;
      point.Y.Value = (double) ((C1FlexGridBase) this.m_flexGrid)[2, 2];
    }
  }

  private void fillZData(CApMFPlacementPoint point)
  {
    if (point.Z.Type == PointType.Step || point.Z.Type == PointType.Free)
    {
      point.Z.Min = (double) ((C1FlexGridBase) this.m_flexGrid)[3, 3];
      point.Z.Max = (double) ((C1FlexGridBase) this.m_flexGrid)[3, 4];
      if (point.Z.Type != PointType.Step)
        return;
      point.Z.Step = (double) ((C1FlexGridBase) this.m_flexGrid)[3, 5];
    }
    else
    {
      if (point.Z.Type != PointType.Exact)
        return;
      point.Z.Value = (double) ((C1FlexGridBase) this.m_flexGrid)[3, 2];
    }
  }

  private void fillRXData(CApMFPlacementPoint point)
  {
    if (point.RX.Type == PointType.Step || point.RX.Type == PointType.Free)
    {
      point.RX.Min = (double) ((C1FlexGridBase) this.m_flexGrid)[4, 3];
      point.RX.Max = (double) ((C1FlexGridBase) this.m_flexGrid)[4, 4];
      if (point.RX.Type != PointType.Step)
        return;
      point.RX.Step = (double) ((C1FlexGridBase) this.m_flexGrid)[4, 5];
    }
    else
    {
      if (point.RX.Type != PointType.Exact)
        return;
      point.RX.Value = (double) ((C1FlexGridBase) this.m_flexGrid)[4, 2];
    }
  }

  private void fillRYData(CApMFPlacementPoint point)
  {
    if (point.RY.Type == PointType.Step || point.RY.Type == PointType.Free)
    {
      point.RY.Min = (double) ((C1FlexGridBase) this.m_flexGrid)[5, 3];
      point.RY.Max = (double) ((C1FlexGridBase) this.m_flexGrid)[5, 4];
      if (point.RY.Type != PointType.Step)
        return;
      point.RY.Step = (double) ((C1FlexGridBase) this.m_flexGrid)[5, 5];
    }
    else
    {
      if (point.RY.Type != PointType.Exact)
        return;
      point.RY.Value = (double) ((C1FlexGridBase) this.m_flexGrid)[5, 2];
    }
  }

  private void fillRZData(CApMFPlacementPoint point)
  {
    if (point.RZ.Type == PointType.Step || point.RZ.Type == PointType.Free)
    {
      point.RZ.Min = (double) ((C1FlexGridBase) this.m_flexGrid)[6, 3];
      point.RZ.Max = (double) ((C1FlexGridBase) this.m_flexGrid)[6, 4];
      if (point.RZ.Type != PointType.Step)
        return;
      point.RZ.Step = (double) ((C1FlexGridBase) this.m_flexGrid)[6, 5];
    }
    else
    {
      if (point.RZ.Type != PointType.Exact)
        return;
      point.RZ.Value = (double) ((C1FlexGridBase) this.m_flexGrid)[6, 2];
    }
  }

  private string TypeToString(PointType type)
  {
    switch (type)
    {
      case PointType.Exact:
        return "Exact";
      case PointType.Step:
        return "Step";
      case PointType.Free:
        return "Free";
      default:
        return "";
    }
  }

  private PointType StringToType(string str)
  {
    switch (str)
    {
      case "Exact":
        return PointType.Exact;
      case "Free":
        return PointType.Free;
      case "Step":
        return PointType.Step;
      default:
        return PointType.Exact;
    }
  }

  private void disableAllCells()
  {
    for (int index = 1; index < ((RowColCollection) ((C1FlexGridBase) this.m_flexGrid).Rows).Count; ++index)
    {
      ((C1FlexGridBase) this.m_flexGrid).SetCellStyle(index, 1, ((C1FlexGridBase) this.m_flexGrid).Styles["Fixed"]);
      ((C1FlexGridBase) this.m_flexGrid).SetCellStyle(index, 2, ((C1FlexGridBase) this.m_flexGrid).Styles["Fixed"]);
      ((C1FlexGridBase) this.m_flexGrid).SetCellStyle(index, 3, ((C1FlexGridBase) this.m_flexGrid).Styles["Fixed"]);
      ((C1FlexGridBase) this.m_flexGrid).SetCellStyle(index, 4, ((C1FlexGridBase) this.m_flexGrid).Styles["Fixed"]);
      ((C1FlexGridBase) this.m_flexGrid).SetCellStyle(index, 5, ((C1FlexGridBase) this.m_flexGrid).Styles["Fixed"]);
      ((C1FlexGridBase) this.m_flexGrid)[index, 1] = (object) null;
      ((C1FlexGridBase) this.m_flexGrid)[index, 2] = (object) null;
      ((C1FlexGridBase) this.m_flexGrid)[index, 3] = (object) null;
      ((C1FlexGridBase) this.m_flexGrid)[index, 4] = (object) null;
      ((C1FlexGridBase) this.m_flexGrid)[index, 5] = (object) null;
    }
  }

  private void SaveChangedPoint(CApMFPlacementPoint point)
  {
    for (int index = 0; index < this.m_pointsList.Count; ++index)
    {
      if (point.Name == ((CApMFPlacementPoint) this.m_pointsList[index]).Name)
      {
        if (this.isNewPointCreated)
          this.m_pointsList[index] = (object) point;
        else
          this.setPointValues((CApMFPlacementPoint) this.m_pointsList[index]);
        this.isNewPointCreated = false;
        break;
      }
    }
  }

  private void m_intermediateCheckBox_CheckedChanged(object sender, EventArgs e)
  {
    if (this.m_intermediateCheckBox.Checked)
    {
      this.m_intermediateUnitText.ReadOnly = false;
      this.m_intermediateUnitText.Enabled = true;
      this.m_intermediateUnitText.Focus();
    }
    else
    {
      this.m_intermediateUnitText.ReadOnly = true;
      this.m_intermediateUnitText.Enabled = false;
    }
  }

  private void m_pointsListView_SelectedIndexChanged(object sender, EventArgs e)
  {
    if (this.m_pointsListView.SelectedItems.Count == 0)
      this.m_deleteButton.Enabled = false;
    else
      this.m_deleteButton.Enabled = true;
  }

  private void CUiMFSetFixtureBasePlacementPointsDlg_FormClosing(
    object sender,
    FormClosingEventArgs e)
  {
    this.m_intermediateUnitText.LoseFocus();
  }

  public ArrayList getPointsList() => this.m_pointsList;

  protected virtual void Dispose(bool disposing)
  {
    if (disposing && this.components != null)
      this.components.Dispose();
    base.Dispose(disposing);
  }

  private void InitializeComponent()
  {
    ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof (CUiMFSetFixtureBasePlacementPointsDlg));
    this.m_okButton = new Button();
    this.m_newButton = new Button();
    this.m_deleteButton = new Button();
    this.m_intermediateCheckBox = new CheckBox();
    this.m_flexGrid = new TxFlexGrid();
    this.m_pointsListView = new ListView();
    this.m_columnHeader = new ColumnHeader();
    this.m_intermediateUnitText = new TxObjEditBoxCtrl();
    this.m_cancelButton = new Button();
    ((ISupportInitialize) this.m_flexGrid).BeginInit();
    ((Control) this).SuspendLayout();
    this.m_okButton.Location = new Point(384, 203);
    this.m_okButton.Name = "m_okButton";
    this.m_okButton.Size = new Size(75, 23);
    this.m_okButton.TabIndex = 0;
    this.m_okButton.Text = "OK";
    this.m_okButton.UseVisualStyleBackColor = true;
    this.m_okButton.Click += new EventHandler(this.m_okButton_Click);
    this.m_newButton.Location = new Point(12, 112 /*0x70*/);
    this.m_newButton.Name = "m_newButton";
    this.m_newButton.Size = new Size(75, 23);
    this.m_newButton.TabIndex = 3;
    this.m_newButton.Text = "New...";
    this.m_newButton.UseVisualStyleBackColor = true;
    this.m_newButton.Click += new EventHandler(this.m_newButton_Click);
    this.m_deleteButton.Enabled = false;
    this.m_deleteButton.Location = new Point(92, 112 /*0x70*/);
    this.m_deleteButton.Name = "m_deleteButton";
    this.m_deleteButton.Size = new Size(75, 23);
    this.m_deleteButton.TabIndex = 4;
    this.m_deleteButton.Text = "Delete";
    this.m_deleteButton.UseVisualStyleBackColor = true;
    this.m_deleteButton.Click += new EventHandler(this.m_deleteButton_Click);
    this.m_intermediateCheckBox.AutoSize = true;
    this.m_intermediateCheckBox.Location = new Point(12, 165);
    this.m_intermediateCheckBox.Name = "m_intermediateCheckBox";
    this.m_intermediateCheckBox.Size = new Size(84, 17);
    this.m_intermediateCheckBox.TabIndex = 5;
    this.m_intermediateCheckBox.Text = "Intermediate";
    this.m_intermediateCheckBox.UseVisualStyleBackColor = true;
    this.m_intermediateCheckBox.CheckedChanged += new EventHandler(this.m_intermediateCheckBox_CheckedChanged);
    ((C1FlexGridBase) this.m_flexGrid).ColumnInfo = componentResourceManager.GetString("m_flexGrid.ColumnInfo");
    ((Control) this.m_flexGrid).Enabled = false;
    ((C1FlexGridBase) this.m_flexGrid).HighLight = (HighLightEnum) 0;
    ((C1FlexGridBase) this.m_flexGrid).KeyActionTab = (KeyActionEnum) 2;
    ((Control) this.m_flexGrid).Location = new Point(185, 12);
    ((Control) this.m_flexGrid).Name = "m_flexGrid";
    ((RowColCollection) ((C1FlexGridBase) this.m_flexGrid).Rows).Count = 7;
    ((ScrollableControl) this.m_flexGrid).ScrollBars = ScrollBars.None;
    ((C1FlexGridBase) this.m_flexGrid).ShowButtons = (ShowButtonsEnum) 2;
    ((Control) this.m_flexGrid).Size = new Size(355, 123);
    ((C1FlexGridBase) this.m_flexGrid).StyleInfo = componentResourceManager.GetString("m_flexGrid.StyleInfo");
    ((Control) this.m_flexGrid).TabIndex = 7;
    ((C1FlexGridBase) this.m_flexGrid).BeforeSelChange += new RangeEventHandler(this.m_flexGrid_BeforeSelChange);
    ((C1FlexGridBase) this.m_flexGrid).AfterEdit += new RowColEventHandler(this.m_flexGrid_AfterEdit);
    ((C1FlexGridBase) this.m_flexGrid).BeforeEdit += new RowColEventHandler(this.m_flexGrid_BeforeEdit);
    this.m_pointsListView.Alignment = ListViewAlignment.Default;
    this.m_pointsListView.Columns.AddRange(new ColumnHeader[1]
    {
      this.m_columnHeader
    });
    this.m_pointsListView.FullRowSelect = true;
    this.m_pointsListView.HideSelection = false;
    this.m_pointsListView.Location = new Point(12, 12);
    this.m_pointsListView.MultiSelect = false;
    this.m_pointsListView.Name = "m_pointsListView";
    this.m_pointsListView.ShowItemToolTips = true;
    this.m_pointsListView.Size = new Size(155, 94);
    this.m_pointsListView.TabIndex = 8;
    this.m_pointsListView.UseCompatibleStateImageBehavior = false;
    this.m_pointsListView.View = View.Details;
    this.m_pointsListView.AfterLabelEdit += new LabelEditEventHandler(this.m_pointsListView_AfterLabelEdit);
    this.m_pointsListView.SelectedIndexChanged += new EventHandler(this.m_pointsListView_SelectedIndexChanged);
    this.m_pointsListView.ItemSelectionChanged += new ListViewItemSelectionChangedEventHandler(this.m_pointsListView_ItemSelectionChanged);
    this.m_columnHeader.Text = "                 Points";
    this.m_columnHeader.TextAlign = HorizontalAlignment.Center;
    this.m_columnHeader.Width = 151;
    this.m_intermediateUnitText.ListenToPick = false;
    ((Control) this.m_intermediateUnitText).Location = new Point(102, 165);
    ((Control) this.m_intermediateUnitText).Name = "m_intermediateUnitText";
    this.m_intermediateUnitText.Object = (ITxObject) null;
    this.m_intermediateUnitText.PickLevel = (TxPickLevel) 1;
    this.m_intermediateUnitText.ReadOnly = false;
    ((Control) this.m_intermediateUnitText).Size = new Size(272, 20);
    ((Control) this.m_intermediateUnitText).TabIndex = 9;
    this.m_intermediateUnitText.ValidatorType = (TxValidatorType) 1;
    this.m_cancelButton.DialogResult = DialogResult.Cancel;
    this.m_cancelButton.Location = new Point(465, 203);
    this.m_cancelButton.Name = "m_cancelButton";
    this.m_cancelButton.Size = new Size(75, 23);
    this.m_cancelButton.TabIndex = 10;
    this.m_cancelButton.Text = "Cancel";
    this.m_cancelButton.UseVisualStyleBackColor = true;
    this.m_cancelButton.Click += new EventHandler(this.m_cancelButton_Click);
    ((Form) this).AcceptButton = (IButtonControl) this.m_okButton;
    ((ContainerControl) this).AutoScaleDimensions = new SizeF(6f, 13f);
    ((ContainerControl) this).AutoScaleMode = AutoScaleMode.Font;
    ((Form) this).CancelButton = (IButtonControl) this.m_cancelButton;
    ((Form) this).ClientSize = new Size(552, 238);
    ((Control) this).Controls.Add((Control) this.m_cancelButton);
    ((Control) this).Controls.Add((Control) this.m_intermediateUnitText);
    ((Control) this).Controls.Add((Control) this.m_pointsListView);
    ((Control) this).Controls.Add((Control) this.m_flexGrid);
    ((Control) this).Controls.Add((Control) this.m_intermediateCheckBox);
    ((Control) this).Controls.Add((Control) this.m_deleteButton);
    ((Control) this).Controls.Add((Control) this.m_newButton);
    ((Control) this).Controls.Add((Control) this.m_okButton);
    ((Form) this).FormBorderStyle = FormBorderStyle.FixedDialog;
    ((Form) this).Icon = (Icon) componentResourceManager.GetObject("$this.Icon");
    ((Form) this).MaximizeBox = false;
    ((Form) this).MinimizeBox = false;
    ((Control) this).Name = nameof (CUiMFSetFixtureBasePlacementPointsDlg);
    ((Control) this).Text = "Placement Points";
    ((Form) this).TopMost = true;
    ((Form) this).ShowIcon = false;
    ((Form) this).FormClosing += new FormClosingEventHandler(this.CUiMFSetFixtureBasePlacementPointsDlg_FormClosing);
    ((ISupportInitialize) this.m_flexGrid).EndInit();
    ((Control) this).ResumeLayout(false);
    ((Control) this).PerformLayout();
  }
}
